//
//  QZUserInfo.m
//  WeiWeiHaircut
//
//  Created by 上官惠阳 on 15/12/4.
//  Copyright © 2015年 超群. All rights reserved.
//

#import "QZUserInfo.h"
#import "QZUserModel.h"
#import "QZDateManager.h"
@implementation QZUserInfo
+(BOOL)userMsgIsKeep
{
    if ([[[TMCache sharedCache] objectForKey:@"userMsgIsKeep"] intValue] == 1) {
        return YES;
    }
    return NO;
}
//[@"昵称",@"性别",@"地区",@"生日",@"联系电话",@"签名"]
+(NSString *)userName
{
    return [[TMCache sharedCache] objectForKey:@"userName"];
}
+(NSString *)password
{
    return [[TMCache sharedCache] objectForKey:@"password"];
}

+(NSString *)userId
{
    return [[TMCache sharedCache] objectForKey:@"userId"];
}
//用户昵称
+(NSString *)nickName
{
    NSString *n= [[TMCache sharedCache] objectForKey:@"nickName"];
    return n?n:@"暂无签名";
}
//手机号
+(NSString *)usertel
{
    return [[TMCache sharedCache] objectForKey:@"usertel"];
}
+(NSString *)userimg
{
    return [[TMCache sharedCache] objectForKey:@"userimg"];
}
//用户头像image
+(UIImage *)headImage
{
    UIImage *image = [[TMCache sharedCache] objectForKey:@"headImage"];
    if (image == nil) {
        image = [UIImage imageNamed:@"1123.jpg"];
    }
    return image;
}
+(NSString *)userday
{
    NSString *u = [[TMCache sharedCache] objectForKey:@"userday"];
    return u?u:@"暂无信息";
}
//会员等级
+(NSString *)userHYdjId
{
    return [[TMCache sharedCache] objectForKey:@"userHYdjId"];
}
//用户类型
+(NSString *)userType
{
    return [[TMCache sharedCache] objectForKey:@"user_type"];
}
//用户签名
+(NSString *)sign
{
    NSString *s = [[TMCache sharedCache] objectForKey:@"sign"];
    return s?s:@"暂无签名";
}
//用户性别
+(NSString *)sex
{   NSString *s= [[TMCache sharedCache] objectForKey:@"sex"];
    if ([s integerValue] == 1) {
        return @"男";
    }else if ([s integerValue] == 2){
        return @"女";
    }else{
        return @"保密";
    }
    return @"暂无信息";
}
// city_data是一个二位数组（citys）省份（city）城市
+(NSString *)address
{
    NSString *d =[[TMCache sharedCache] objectForKey:@"address"];
    return d?d:@"暂无地址";
}
+(NSString *)myLoction
{
    return [[TMCache sharedCache] objectForKey:@"myLoction"];
}
+(void)keepUserMsgWithUserModel:(QZUserModel *)userModel
{
    [[TMCache sharedCache] setObject:userModel.id forKey:@"userId"];
    [[TMCache sharedCache] setObject:userModel.nickName forKey:@"nickName"];
    [[TMCache sharedCache] setObject:userModel.usertel forKey:@"usertel"];
    [[TMCache sharedCache] setObject:userModel.userimg forKey:@"userimg"];
    [[TMCache sharedCache] setObject:userModel.userHYdjId forKey:@"userHYdjId"];
    
   NSString *userDay = [[QZDateManager sharedDateManager] secondToStringTIme:userModel.userday];
    
    [[TMCache sharedCache] setObject:userDay forKey:@"userday"];
    [[TMCache sharedCache] setObject:userModel.sex forKey:@"sex"];
    [[TMCache sharedCache] setObject:userModel.sign forKey:@"sign"];
    [[TMCache sharedCache] setObject:userModel.userdizhi forKey:@"address"];
    [[TMCache sharedCache] setObject:userModel.user_type forKey:@"user_type"];
    
    [[TMCache sharedCache] setObject:@(1) forKey:@"userMsgIsKeep"];
    
//    UIImage *headImg = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:userModel.userimg]]];
    [[TMCache sharedCache] setObject:userModel.userimg forKey:@"headImageURL"];
}
@end
